package com.cx330;

public class Example90_02 {
    public static void main(String[] args) {
        BikeFactory bikeFactory = new BikeFactory();
        Bike02 bike = bikeFactory.getVehicle();
        bike.drive();
        ElectromobileFactory electromobileFactory = new ElectromobileFactory();
        Electromobile02 electromobile = electromobileFactory.getVehicle();
        electromobile.drive();
        CarFactory carFactory = new CarFactory();
        Car02 car = carFactory.getVehicle();
        car.drive();
    }
}

abstract class Vehicle02 { // 抽象产品父类
    public abstract void drive();
}

interface VehicleFactory02 {
    Vehicle02 getVehicle();
}

class Bike02 extends Vehicle02 {

    @Override
    public void drive() {
        System.out.println("骑自行车锻炼身体！");
    }
}

class BikeFactory implements VehicleFactory02 {

    @Override
    public Bike02 getVehicle() {
        return new Bike02();
    }
}

class Electromobile02 extends Vehicle02 {

    @Override
    public void drive() {
        System.out.println("骑电动车送外卖！");
    }
}

class ElectromobileFactory implements VehicleFactory02 {

    @Override
    public Electromobile02 getVehicle() {
        return new Electromobile02();
    }
}

class Car02 extends Vehicle02 {

    @Override
    public void drive() {
        System.out.println("开车去上班！");
    }
}

class CarFactory implements VehicleFactory02 {

    @Override
    public Car02 getVehicle() {
        return new Car02();
    }
}
